using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.PharmacyDomain;
using ShivamEMR.Model.DataInterfaces.PharmacyDataInterf;
using ShivamEMR.Model;
//using ShivamEMR.Web.Areas.Pharmacy.Models;

namespace ShivamEMR.Web.Areas.Pharmacy.Controllers
{   
    public class DrugClassController : Controller
    {
		private readonly IDrugClassRepository drugclassRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public DrugClassController() 
        {
            drugclassRepository = Registry.RepositoryFactory.GetDrugClassRepository();
        }

        public DrugClassController(IDrugClassRepository drugclassRepository)
        {
			this.drugclassRepository = drugclassRepository;
        }

        //
        // GET: /DrugClass/

        public ViewResult Index()
        {
           // return View(drugclassRepository.AllIncluding(drugclass => drugclass.DrugGenerics, drugclass => drugclass.DrugBrands));
            return View(drugclassRepository.All);
        }

        //
        // GET: /DrugClass/Details/5

        public ViewResult Details(System.Guid id)
        {
            return View(drugclassRepository.Find(id));
        }

        //
        // GET: /DrugClass/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /DrugClass/Create

        [HttpPost]
        public ActionResult Create(DrugClass drugclass)
        {
            if (ModelState.IsValid) {
                drugclassRepository.InsertOrUpdate(drugclass);
                drugclassRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /DrugClass/Edit/5
 
        public ActionResult Edit(System.Guid id)
        {
             return View(drugclassRepository.Find(id));
        }

        //
        // POST: /DrugClass/Edit/5

        [HttpPost]
        public ActionResult Edit(DrugClass drugclass)
        {
            if (ModelState.IsValid) {
                drugclassRepository.InsertOrUpdate(drugclass);
                drugclassRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /DrugClass/Delete/5
 
        public ActionResult Delete(System.Guid id)
        {
            return View(drugclassRepository.Find(id));
        }

        //
        // POST: /DrugClass/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(System.Guid id)
        {
            var dclass = drugclassRepository.Find(id);
            drugclassRepository.Delete(dclass);
            drugclassRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

